package bb.lanxing.util;

import android.app.DatePickerDialog;
import android.content.Context;

import java.util.Calendar;

import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;

public final class BirthdaySelectDialogUtil {
    public static final Companion Companion = new Companion(null);

    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }

        public void showBirthDialog(Context context, final long j, final Function1<? super Long, Unit> selectCallBack) {
            final Calendar calendar = Calendar.getInstance();
            if (j == 0) {
                calendar.setTimeInMillis(System.currentTimeMillis());
            } else {
                calendar.setTimeInMillis(1000 * j);
            }
            new DatePickerDialog(context, (datePicker, i, i2, i3) -> {
                calendar.set(1, i);
                calendar.set(2, i2);
                calendar.set(5, i3);
                long timeInMillis = calendar.getTimeInMillis() / 1000;
                if (j != timeInMillis) {
                    selectCallBack.invoke(timeInMillis);
                }

            }, calendar.get(1), calendar.get(2), calendar.get(5)).show();
        }
    }
}